home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
FishMarket 1.0
/
FishMarket v1.0.iso
/
fishies
/
526-550
/
disk_540
/
wbrun
/
wbrun.c
< prev
next >
Wrap
C/C++ Source or Header
|
1992-05-06
|
3KB
|
109 lines
/*
* WBRun.c - Copyright © 1990 by S.R. & P.C.
*
* Created: 28 Apr 1991 20:17:57
* Modified: 07 Jul 1991 11:15:08
*
* Make>> copy ParM.sym ram: clone quick
* Make>> cc -qf -ps -wp -wd -wu -wr -sb -so -hi ram:ParM.sym <file>.c
* Make>> ln -m <file>.o -larpsc
*/
#include "ParMBase.h"
#define USAGE "Usage: WBRun Prog [args] [STACK size] [PRI pri] [DELAY sec]"
#define TEMPLATE "Prog/a,args/...,STACK/k,PRI/k,DELAY/k"
struct ParMBase *ParMBase;
struct ExecBase *SysBase;
struct ArpBase *ArpBase;
long DosWrite(BPTR file, char *buffer, long length);
#pragma amicall(DOSBase, 0x30, DosWrite(d1,d2,d3))
void exit(int code)
{
CloseLibrary(ParMBase);
Exit(code);
}
void main(int argc, char **argv, struct Process *pp)
{
struct Extended_WBStartup *EWBS;
struct ParMConfig ParMConfig;
char **args;
long Stack;
BYTE Pri;
short i;
short NumArg = 1; /* 1 by default (or 2 if PROJECT ) */
FreeRepliedWBMessages();
if (argc == 0) {
Puts(USAGE);
return;
}
ParMConfig.DefaultStack = ((struct CommandLineInterface *)(pp->pr_CLI << 2))->cli_DefaultStack << 2;
Stack = Atol(argv[2]);
Pri = Atol(argv[3]);
ParMConfig.ReqTitle = "WBRun";
if (args = (char **)argv[1]) {
while(*args++)
NumArg++;
}
EWBS = AllocMem(sizeof(struct Extended_WBStartup), MEMF_PUBLIC|MEMF_CLEAR);
if ((EWBS->ArgArray = AllocMem((NumArg+1)*sizeof(struct WBArg), MEMF_PUBLIC|MEMF_CLEAR))) {
EWBS->ArrayLength = NumArg + 1;
EWBS->WBStartup.sm_NumArgs = NumArg;
EWBS->WBStartup.sm_ArgList = &EWBS->ArgArray[1];
if (MakeWBArg(&ParMConfig, EWBS->WBStartup.sm_ArgList, argv[0])) {
if (args = (char **)argv[1]) {
i = 1;
while(*args) {
if (!MakeWBArg(&ParMConfig, &EWBS->WBStartup.sm_ArgList[i++], *args++)) {
WBFree(EWBS);
exit(20);
}
}
}
if (GetTool(&ParMConfig, EWBS, Stack)) {
WBRun(&ParMConfig, EWBS, Pri);
Delay(Atol(argv[4])*50);
return;
}
}
}
WBFree(EWBS);
exit(20);
}
void _main(long alen, char *aptr)
{
struct Library *DOSBase;
register struct Process *pp;
int _argc;
char **_argv;
pp = (struct Process *)SysBase->ThisTask;
if (!(ParMBase = (struct ParMBase *)OpenLibrary("parm.library", 1L))) {
if (DOSBase = OpenLibrary("dos.library", 0L)) {
DosWrite(pp->pr_COS, "You need parm.library V1+\n", 26L);
CloseLibrary(DOSBase);
}
return;
}
ArpBase = ParMBase->ArpBase;
_argv = ArpAlloc(24);
_argc = (int)GADS(aptr, alen, USAGE, _argv, TEMPLATE);
if (_argc < 0) {
Puts(_argv[0]);
exit(20);
}
main(_argc, _argv, pp);
exit(0);
}